package com.dpwx.framework.network;

import java.net.URL;
import java.util.Random;

public class FakeNetworkTask extends BaseNetworkTask {

	public FakeNetworkTask(URL url, IRequest req, INetworkCallback callback) {
		super(url, req, callback);
	}

	@Override
	public void doTask() {
		execute(null);
	}

	@Override
	public void onPostExecute() {
		if (mCallback != null) {
			Random rand = new Random();
			if (rand.nextBoolean()) {
				mCallback.networkFinished(null);
			} else {
				mCallback.networkError(null);
			}
		}
	}

	@Override
	protected Void doInBackground(Void... params) {
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

}
